/*********************************************************************************/
/*                                                                               */
/*      WDG Driver                                                               */
/*                                                                               */
/*      Last updated by:   CBS                                                   */
/*      Last update date:  2013/2/8                                              */
/*      Revision:          0                                                     */
/*      Copyright:         DENSO                                                 */
/*                                                                               */
/*********************************************************************************/

/*********************************************************************************/
/*  include files                                                                */
/*********************************************************************************/
#include "MPC5674F_MVx264.h"
#include "WdgSwt.h"

/*********************************************************************************/
/*  constants                                                                    */
/*********************************************************************************/
extern const Wdg_ConfigType WdgConfigData;
extern U4 iii;

/*********************************************************************************/
/*  API Functions                                                                */
/*********************************************************************************/

/***************************************************************************************************/
/*  Service name    :   Wdg_Cbk_GptNotificationSwt                                                 */
/*  Sync/Async      :   Synchronous                                                                */
/*  Reentrancy      :   Non Reentrant                                                              */
/*  Parameters (in) :   None                                                                       */
/*  Return value    :   None                                                                       */
/*  Discription     :   Watchdog triggering routine in case it is called from a GPT callback.      */
/***************************************************************************************************/
void Wdg_Cbk_GptNotificationSwt(void)
{
    U2 ServiceCode;

    if(WdgConfigData.ServiceMode == WDG_FIXED_SERVICE_MODE)
    {
        SWT.SR.B.WSC = 0xA602;
        SWT.SR.B.WSC = 0xB480;
    }
    else  /* WDG_KEYED_SERVICE_MODE */
    {
        ServiceCode = SWT.SK.B.SK;
        ServiceCode = (17 * ServiceCode + 3) % (1 << 16);  /* 1 << 16 = 2 ^ 16 = 65536 */
        SWT.SR.B.WSC = ServiceCode;
        ServiceCode = (17 * ServiceCode + 3) % (1 << 16);
        SWT.SR.B.WSC = ServiceCode;
    }
    iii++;
}

/**** End Of File ****************************************************************/
